package com.my.test.design.Prototype;

public class Test {

    /**
     * 通过拷贝的方式创建对象
     * 浅拷贝：只拷贝对象的引用，不拷贝对象的值
     * 深拷贝：不光拷贝对象的引用，还拷贝对象的值
     *
     * @param args
     * @throws CloneNotSupportedException
     */
    public static void main(String[] args) throws CloneNotSupportedException {
        Head h = new Head();
        Body body = new Body(h);

        Body body2 = body.clone();

        System.out.println(body);
        System.out.println(body2);

        System.out.println(body.getHead());
        System.out.println(body2.getHead());


    }

}
